var data2108 = ["李朝恒","李露","陈慧莹","杨色安","陆方梅","何坪坪","李倩","蓝佳妮","韦淑月","彭晴","蓝有进","朱新基","宋雅轩","何健欣","邱宏芳","卢鹏","文杰","陈继天","黄烨桐","张语桥","沈光传","黄麒榕","黄满奕","梁春兰","韦慧雪","莫欣欣","邓雨薇","李晶晶","黄开健","龚秋婷","李传标","冯雨柔","奉海燕","龙思连","周伟凤","黄凤华","陆嘉明","雷正","黎杰才","谭政"];

var data2107 = ["云情优","姚荣能","韦举省","侯颖","廖家锐","顾羽","农晓贵","莫光福","胡振立","张覃星","梁金帅","石雨樱","韩开选","韦旋","冯勤羽","陆凤莺","农盛圣","张海琳","周鸿辉","莫超贵","磨兴涛","韦柳凤","曾子洋","岑斌才","王少康","叶雨晴","黄成聪","陆莹莹","何美凤","秦威","凌正宇","张卓灿","韦瑜","陆杰德","王海清","覃锋","覃昌旭","潘臣官","李炜","劳承彬"];

var data2106 = ["于水青","廖侦羽","覃凌意","张癸艳","赖锦薇","王艳泓","周高全","吴锦华","黄东东","张国彬","董燕勤","苏姗姗","奉莹","龙华盛","黄美凤","陈宇扬","吴浩信","凌威","黄丽芳","王静静","覃秀莲","沈芳婷","文彪","何柏辉","陈东南","黄炳涛","刘彩林","苏张倩","张春玲","林金富","陈钊","刘健","路从政","潘姗姗","林国锦","周毅","廖振捷","黄天福","卢为迈","杨阳"];

var ulobj = document.getElementById("nameData");
var lis = ulobj.children;
var myselect = document.getElementById('sclass');
var myclass = "-1";
myselect.onchange = function() {
    var bi = this.selectedIndex;
    var mybj = this[bi].value;
    myclass = mybj;
    if(mybj.indexOf("2108")>=0){
         mydata = data2108;
    } else if(mybj.indexOf("2107")>=0){
		mydata = data2107;
	} else{
         mydata = data2106;
    }
    
    for(var i=0;i<lis.length;i++){
        lis[i].innerHTML=mydata[i];
    }
}

var myNum = 0;
var numselect = document.getElementById('snum');
numselect.onchange = function() {
    var bi = this.selectedIndex;
    myNum = this[bi].value;
}

var btn1 = document.getElementById("btnstart");


btn1.onclick = function(){
    if(myclass=="-1"){
        alert('请选择班级！');
        return;
    }else if(myNum==0){
        alert('请选择人数！');
        return;
    }
    clearInterval(window.idTime);
    window.idTime =  setInterval(function(){
        for(var i=0;i<lis.length;i++){
            lis[i].style.backgroundColor="#CCC";
        }
    
        // var myNum = document.getElementById('num1').value;

        var mybian = [];
        while(mybian.length<myNum){
            var ba = Math.floor(Math.random()*(200-1)+1);
            ba %= 40;
            if(mybian.indexOf(ba)<0){
                mybian.push(ba);
            } 
        }
        if(mybian.length!=myNum){
            alert(myNum);
        }
        for(var i=0;i<mybian.length;i++){
            lis[mybian[i]].style.backgroundColor="red";
        }
    },100);
}

var btn2 = document.getElementById("btnend");
btn2.onclick = function(){
    clearInterval(window.idTime);
}